/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2023-01-06
 * Time: 19:01
 */
public class Solution4 {
    public static ListNode oddEvenList(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode eveHead = head.next;

        ListNode odd = head;
        ListNode eve = head.next;

        while (eve != null && eve.next != null) {
            odd.next = eve.next;
            odd = odd.next;
            eve.next = odd.next;
            eve = eve.next;
        }

        odd.next = eveHead;
        return head;
    }

    public static void main(String[] args) {
        MySingleList list = new MySingleList();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.addLast(5);

        ListNode node = oddEvenList(list.head);
        System.out.println();
    }
}
